var area = require('../../utils/area.js');
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    openSelect: {
      type: Boolean,
      value: false
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    areaList: area.areaList
  },

  /**
   * 组件的方法列表
   */
  methods: {
    onClose() {
      this.setData({
        openSelect: false
      });
    },
    onConfirm(e) {
      let value = e.detail;
      let province = this.formatValue(value.values[0]);
      let city = this.formatValue(value.values[1]);
      let county = this.formatValue(value.values[2]);
      this.triggerEvent('callback', {
        e: value,
        province,
        city,
        county,
        value: province + city + county
      })
    },
    formatValue(arg) {
      if (arg) {
        return arg.name;
      }
      return '';
    },
  }
})